package leecode

func numSubarrayProductLessThanK(nums []int, k int) (result int) {
	if k <= 1 {
		return 0
	}
	low, last, temp := 0, 0, 1
	for last < len(nums) {
		temp *= nums[last]
		for temp >= k {
			temp = temp / nums[low]
			low++
		}
		result += last - low + 1
		last++
	}
	return result
}
